home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 8206 / 8206.xpi / content / webmail / aol.js next >
Text File  |  2010-02-02  |  5KB  |  182 lines

  1. window.addEventListener("load",function(event){aolsig.pageload(event)},false);
  2. window.addEventListener("unload",function(event){aolsig.uninitSig(event)},false);
  3.  
  4. var aolsig =
  5. {
  6.     current: null,
  7.     pageload: function (event)
  8.     {
  9.         try
  10.         {
  11.             wisestampsig.refreshCallback = aolsig.refreshSignature;
  12.             setTimeout(function ()
  13.             {
  14.                 aolsig.init();
  15.             },
  16.             0);
  17.         } catch(e)
  18.         {
  19.             //      WISELOG(e);
  20.         }
  21.     },
  22.     uninitSig: function ()
  23.     {
  24.         var viewDiv = document.getElementById("ws_view");
  25.         if (viewDiv) viewDiv.removeEventListener("DOMNodeInserted", aolsig.composeInserted, false);
  26.         var compose = document.getElementById("composeMessage");
  27.         if (compose)
  28.         {
  29.             try
  30.             {
  31.                 this._composeListener = false;
  32.                 compose.removeEventListener("DOMAttrModified", aolsig.composeModified, false);
  33.             } catch(e)
  34.             {
  35.  
  36.             }
  37.         }
  38.         this.uninitView();
  39.     },
  40.     uninitView: function ()
  41.     {
  42.         if (this.current && this["uninit" + this.current])
  43.         {
  44.             this["uninit" + this.current]();
  45.         }
  46.     },
  47.     init: function ()
  48.     {
  49.         //    WISELOG("SetupCompose");
  50.         var viewDiv = document.getElementById("ws_view");
  51.         //    WISELOG("viewDiv: "+viewDiv);
  52.         if (viewDiv) 
  53.             viewDiv.addEventListener("DOMNodeInserted", aolsig.composeInserted, false);
  54.     },
  55.     get _currentMode()
  56.     {
  57.         var eles = evaluateXPath(document, "//div[contains(@class,'navItemCurrent')]");
  58.         if (eles && eles.length > 0)
  59.         {
  60.             //      WISELOG("eles: "+eles.length);
  61.             return eles[0].getAttribute("title");
  62.         }
  63.         return null;
  64.     },
  65.     composeInserted: function (event)
  66.     {
  67.         var match = null;
  68.         if (event.target && event.target.id)
  69.         {
  70.             //WISELOG("inserted: "+event.target.id);
  71.             if (event.target.id == "composeMessage")
  72.             {
  73.                 setTimeout(function ()
  74.                 {
  75.                     /* let the other inner elements load, too */
  76.                     //          WISELOG("ComposeInserted");
  77.                     aolsig.setupCompose(event.target);
  78.                 },
  79.                 100);
  80.             }
  81.         }
  82.     },
  83.     composeModified: function (event)
  84.     {
  85.         //WISELOG("Compose Modified: "+event);
  86.         //WISELOG("Attribute: "+event.attrName);
  87.         //WISELOG("previous: "+event.prevValue);
  88.         //WISELOG("new: "+event.newValue);
  89.         //WISELOG("real: "+event.target.getAttribute(event.attrName));
  90.         if (aolsig.iframe && event.attrName == "style")
  91.         {
  92.             aolsig.insertSignature(aolsig.iframe);
  93.         }
  94.     },
  95.     setupCompose: function (view)
  96.     {
  97.         if (!this._composeListener)
  98.         {
  99.             this._composeListener = true;
  100.             view.addEventListener("DOMAttrModified", aolsig.composeModified, false);
  101.         }
  102.         var toolbar = evaluateXPath(document, "//div[@id='composeMessage']//div[@class='containerNode']")[0];
  103.         //var toolbar = evaluateXPath(document, "//div[@id='composeMessage']//div[contains(@class,'toolbar')]")[0];
  104.         this.addWisestampIcon(toolbar);
  105.         var iframes = view.getElementsByTagName("iframe");
  106.         var iframe = iframes[0];
  107.         this.insertSignature(iframe);
  108.     },
  109.     addWisestampIcon: function (toolbar)
  110.     {
  111.         //    WISELOG("AddWisestampIcon");
  112.         if (!wisestampsig.showButton) return;
  113.         try
  114.         {
  115.             var buttons = evaluateXPath(document, "//div[@class='composeMessage']//div[contains(@class,'wsButton rightBorder')]");
  116.             var cancelButton = buttons[buttons.length - 1];
  117.             var div = document.createElement("div");
  118.             div.setAttribute("id", "ws_widget_WSButton_Foxy");
  119.             div.setAttribute("class", "wsButton wsIconButton rightBorder");
  120.             div.setAttribute("dojoattachevent", "onclick: _onClick, onmouseover: onMouseOver, onmousedown: onMouseDown, onkeypress: onKeyPress")
  121.             div.setAttribute("widgetid", "ws_widgeht_WSButton_Foxy");
  122.             div.setAttribute("style", "float: left; height: 24px; width: 32px;");
  123.             div.setAttribute("title", "");
  124.             var nobr = document.createElement("nobr");
  125.             nobr.setAttribute("class", "content");
  126.             nobr.setAttribute("dojoattachpoint", "contentNode");
  127.             nobr.setAttribute("style", "width: 15px; height: 14px;");
  128.             var label = document.createElement("div");
  129.             label.setAttribute("class", "label");
  130.             label.setAttribute("dojoattachpoint", "contentNode");
  131.             label.innerHTML = '<img class="icon"' + 'style="background-image: url(' + "'" + wisestampsig.icon + "'" + '); background-position: 0px 0px;;"' + 'src="chrome://wisestamp/skin/space.png"' + '"/>';
  132.  
  133.             nobr.appendChild(label);
  134.             div.appendChild(nobr);
  135.             toolbar.insertBefore(div, cancelButton);
  136.             wisestampsig.initOptionsIcon(div);
  137.         } catch(e)
  138.         {
  139.             //      WISELOG("e: "+e);
  140.         }
  141.     },
  142.     uninitCompose: function ()
  143.     {
  144.  
  145.     },
  146.     iframeTries: 1,
  147.     refreshSignature: function ()
  148.     {
  149.         wisestampsig.insertSignature(aolsig.iframe, false);
  150.     },
  151.     insertSignature: function (iframe)
  152.     {
  153.         this.iframe = iframe;
  154.         if (this._currentMode != "Drafts")
  155.         {
  156.             //this.iframe.addEventListener('load',aolsig.iframeLoad,false);
  157.             this.iframeLoad(false);
  158.         } else
  159.         {
  160.             //      WISELOG("not inserted because it is a draft")
  161.         }
  162.     },
  163.     iframeLoad: function (event)
  164.     {
  165.         setTimeout(function ()
  166.         {
  167.             //      WISELOG("iframe load: "+event);
  168.             //      WISELOG("iframe name: "+aolsig.iframe.getAttribute("name"));
  169.             //      WISELOG("iframe parent: "+aolsig.iframe.parentNode.id);
  170.             wisestampsig.insertSignature(aolsig.iframe, true);
  171.             if (event)
  172.             {
  173.                 try
  174.                 {
  175.                     //aolsig.iframe.removeEventListener('load',aolsig.iframeLoad,false);
  176.                 } catch(e)
  177.                 {}
  178.             }
  179.         },
  180.         !event ? 500 : 0);
  181.     }
  182. };